#!/bin/bash

cygwin=false;
case "`uname`" in
  CYGWIN*) cygwin=true ;;
esac

LOCUTOR_BIN="`which $0`"
if [[ -z "$LOCUTOR_BIN" ]]
then
    LOCUTOR_BIN="$0"
fi
while [[ -L "$LOCUTOR_BIN" ]]
do
    LOCUTOR_BIN="`readlink -f $LOCUTOR_BIN`"
done
LOCUTOR_HOME="`dirname \"$LOCUTOR_BIN\"`"
LOCUTOR_HOME="`cd \"$LOCUTOR_HOME\" ; pwd`"

LOCUTOR_CP=""
for jar in "$LOCUTOR_HOME"/*.jar
do
    LOCUTOR_CP="$LOCUTOR_CP:$jar"
done
for jar in "$LOCUTOR_HOME"/lib/*.jar
do
    LOCUTOR_CP="$LOCUTOR_CP:$jar"
done
LOCUTOR_CP="${LOCUTOR_CP#:}"

if $cygwin ; then
  LOCUTOR_CP="`cygpath --windows --path \"$LOCUTOR_CP\"`"
fi

LOCUTOR_VM_OPTIONS[0]="-Dsun.io.useCanonCaches=false"

LOCUTOR_MAINCLASS=locutor.cli.Locutor
java "${LOCUTOR_VM_OPTIONS[@]}" -cp "$LOCUTOR_CP" $LOCUTOR_MAINCLASS "$@"
